<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Supported String Types</title>
<link rel="stylesheet" href="../../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Chapter 1. Boost.Convert 2.0">
<link rel="up" href="../stream_converter.html" title="boost::cnv::stream Converter">
<link rel="prev" href="locale_support.html" title="Locale Support">
<link rel="next" href="supported_string_types/custom_string_types.html" title="Custom String Types">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="spirit-nav">
<a accesskey="p" href="locale_support.html"><img src="../../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../stream_converter.html"><img src="../../../images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../images/home.png" alt="Home"></a><a accesskey="n" href="supported_string_types/custom_string_types.html"><img src="../../../images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_convert.converters_detail.stream_converter.supported_string_types"></a><a class="link" href="supported_string_types.html" title="Supported String Types">Supported
        String Types</a>
</h4></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="supported_string_types.html#boost_convert.converters_detail.stream_converter.supported_string_types.wide_string">Wide
          String</a></span></dt>
<dt><span class="section"><a href="supported_string_types/custom_string_types.html">Custom
          String Types</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="boost_convert.converters_detail.stream_converter.supported_string_types.wide_string"></a><a class="link" href="supported_string_types.html#boost_convert.converters_detail.stream_converter.supported_string_types.wide_string" title="Wide String">Wide
          String</a>
</h5></div></div></div>
<p>
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">cnv</span><span class="special">::</span><span class="identifier">wstream</span> <span class="identifier">wcnv</span><span class="special">;</span>

<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">convert</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span><span class="identifier">L</span><span class="string">"11"</span><span class="special">,</span> <span class="identifier">wcnv</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">hex</span><span class="special">)).</span><span class="identifier">value_or</span><span class="special">(</span><span class="number">0</span><span class="special">)</span> <span class="special">==</span> <span class="number">17</span><span class="special">);</span> <span class="comment">// 11(16) = 17(10)</span>
<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">convert</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span><span class="identifier">L</span><span class="string">"11"</span><span class="special">,</span> <span class="identifier">wcnv</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">oct</span><span class="special">)).</span><span class="identifier">value_or</span><span class="special">(</span><span class="number">0</span><span class="special">)</span> <span class="special">==</span>  <span class="number">9</span><span class="special">);</span> <span class="comment">// 11(8)  = 9(10)</span>
<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">convert</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span><span class="identifier">L</span><span class="string">"11"</span><span class="special">,</span> <span class="identifier">wcnv</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">dec</span><span class="special">)).</span><span class="identifier">value_or</span><span class="special">(</span><span class="number">0</span><span class="special">)</span> <span class="special">==</span> <span class="number">11</span><span class="special">);</span>

<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">convert</span><span class="special">&lt;</span><span class="identifier">wstring</span><span class="special">&gt;(</span><span class="number">254</span><span class="special">,</span> <span class="identifier">wcnv</span><span class="special">(</span><span class="identifier">arg</span><span class="special">::</span><span class="identifier">base</span> <span class="special">=</span> <span class="identifier">cnv</span><span class="special">::</span><span class="identifier">base</span><span class="special">::</span><span class="identifier">dec</span><span class="special">)).</span><span class="identifier">value_or</span><span class="special">(</span><span class="identifier">L</span><span class="string">"bad"</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">L</span><span class="string">"254"</span><span class="special">);</span>
<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">convert</span><span class="special">&lt;</span><span class="identifier">wstring</span><span class="special">&gt;(</span><span class="number">254</span><span class="special">,</span> <span class="identifier">wcnv</span><span class="special">(</span><span class="identifier">arg</span><span class="special">::</span><span class="identifier">base</span> <span class="special">=</span> <span class="identifier">cnv</span><span class="special">::</span><span class="identifier">base</span><span class="special">::</span><span class="identifier">hex</span><span class="special">)).</span><span class="identifier">value_or</span><span class="special">(</span><span class="identifier">L</span><span class="string">"bad"</span><span class="special">)</span> <span class="special">==</span>  <span class="identifier">L</span><span class="string">"fe"</span><span class="special">);</span>
<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">convert</span><span class="special">&lt;</span><span class="identifier">wstring</span><span class="special">&gt;(</span><span class="number">254</span><span class="special">,</span> <span class="identifier">wcnv</span><span class="special">(</span><span class="identifier">arg</span><span class="special">::</span><span class="identifier">base</span> <span class="special">=</span> <span class="identifier">cnv</span><span class="special">::</span><span class="identifier">base</span><span class="special">::</span><span class="identifier">oct</span><span class="special">)).</span><span class="identifier">value_or</span><span class="special">(</span><span class="identifier">L</span><span class="string">"bad"</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">L</span><span class="string">"376"</span><span class="special">);</span>
</pre>
<p>
          </p>
<p>
</p>
<pre class="programlisting">    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">cnv</span><span class="special">::</span><span class="identifier">wstream</span> <span class="identifier">wcnv</span><span class="special">;</span>

    <span class="identifier">wcnv</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">noskipws</span><span class="special">);</span> <span class="comment">// Do not ignore leading whitespaces</span>

    <span class="identifier">BOOST_TEST</span><span class="special">(</span> <span class="identifier">convert</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span>   <span class="identifier">L</span><span class="string">"123"</span><span class="special">,</span> <span class="identifier">wcnv</span><span class="special">).</span><span class="identifier">value_or</span><span class="special">(</span><span class="number">0</span><span class="special">)</span> <span class="special">==</span> <span class="number">123</span><span class="special">);</span>
    <span class="identifier">BOOST_TEST</span><span class="special">(!</span><span class="identifier">convert</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span> <span class="identifier">L</span><span class="string">"  123"</span><span class="special">,</span> <span class="identifier">wcnv</span><span class="special">));</span>
    <span class="identifier">BOOST_TEST</span><span class="special">(!</span><span class="identifier">convert</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span><span class="identifier">L</span><span class="string">"  123 "</span><span class="special">,</span> <span class="identifier">wcnv</span><span class="special">));</span>

    <span class="identifier">wcnv</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">skipws</span><span class="special">);</span>        <span class="comment">// Ignore leading whitespaces</span>
<span class="comment">//  wcnv(arg::skipws = true); // Ignore leading whitespaces. Alternative interface</span>

    <span class="identifier">BOOST_TEST</span><span class="special">(</span> <span class="identifier">convert</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span> <span class="identifier">L</span><span class="string">"  123"</span><span class="special">,</span> <span class="identifier">wcnv</span><span class="special">).</span><span class="identifier">value_or</span><span class="special">(</span><span class="number">0</span><span class="special">)</span> <span class="special">==</span> <span class="number">123</span><span class="special">);</span>
    <span class="identifier">BOOST_TEST</span><span class="special">(!</span><span class="identifier">convert</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span><span class="identifier">L</span><span class="string">"  123 "</span><span class="special">,</span> <span class="identifier">wcnv</span><span class="special">));</span>
</pre>
<p>
          </p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2009-2022 Vladimir
      Batov<p>
        Distributed under the Boost Software License, Version 1.0. See copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>.
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="locale_support.html"><img src="../../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../stream_converter.html"><img src="../../../images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../images/home.png" alt="Home"></a><a accesskey="n" href="supported_string_types/custom_string_types.html"><img src="../../../images/next.png" alt="Next"></a>
</div>
</body>
</html>
